package com.yr.ryjk.common;

/**
 * 错误类型,0为正常处理返回,1**为客户端错误,2**为服务器错误(具体错误自定义,如101为请求参数错误)
 * @author Rick
 * 
 */
public enum ErrorType{
	SUCCESS							(0, "success"),
	CLIENT_ERROR					(1, "客户端未知错误"),
	SERVER_ERROR					(2, "服务器未知错误"),
	NEED_LOGIN						(-1, "请重新登录"),
	
	REQUEST_PARAMS_ERROR			(101, "请求参数不合法"),
	AUTHORITY_ERROR                 (102, "没有操作权限"),
	SESSION_TIMEOUT_ERROR		    (103, "session已超时"),
	REQUESTED_DATA_NOT_EXIST_ERROR	(104, "请求的数据不存在"),
	LOGIN_ERROR                     (105, "手机号或密码错误"),
	PHONE_HAS_REGISTERED_ERROR      (106, "手机号已注册"),
	INVITED_CODE_NOT_EXIST_ERROR    (107, "邀请码不存在"),
	DATE_PATTERN_ERROR    			(108, "日期格式错误"),
	PASSWORD_ERROR    				(109, "密码错误"),
	CHECKCODE_NOT_EXSIT_ERROR    	(110, "验证码已过期，请重新获取"),
	CHECKCODE_ERROR    				(111, "手机验证码错误"),
	TOKEN_ERROR    				    (112, "用户不存在"),              //令牌错误，用户不存在
	COIN_NOT_ENOUGH_ERROR    		(113, "健康币不足"),
	CONSULT_HAS_END_ERROR           (114, "本次咨询已结束，不允许回复"),
	SYSUSER_REPEATED_ERROR			    (115, "该系统用户已经存在，请重新输入用户名"), 
	COIN_HAS_TOKEN_ERROR			(116, "今天已经领取过，请不要重复领取"), 
	DOCTOR_ALREADY_IN_EXPERT_ERROR  (117, "该医生已属于该分类"), 
	BANK_CARD_EXISTS_ERROR  		(118, "银行卡已经存在"), 
	PAY_TYPE_ERROR  				(119, "支付类型错误"), 
	HAS_FOCUSED_ERROR  				(120, "已关注该医生，不能重复关注"), 
	TEST_SCORE_LAGGER_ERROR  		(121, "测试题分数超过100分"), 
	SCORE_REPEAT_ERROR  		    (122, "不要重复评分"), 
	SHARE_APP_RECORD_TIMES  		(123, "您今日分享的次数已经超过每日分享的上限次数"),
	ASKPRICE_OUT_OF_RANGE           (124, "askprice不能超出范围"), 
	
	DATABASE_ERROR                  (201, "数据库操作出错"),
	SMS_ERROR				        (202, "短信发送失败"),
	HANDLE_FILE_ERROR			    (203, "服务器处理文件出错"),
	UNIONPAY_MATCH_ERROR  			(204, "银联对接出错"), 
	ALIPAY_MATCH_ERROR  			(205, "支付宝对接出错"),
	COIN_MD5_CHECK_ERROR  			(206, "健康币数量出现异常,请联系服务人员"),
	APP_VERSION_ERROR  			    (207, "版本号不能够低于当前最高版本");
	
	
	private int code;
	private String msg;

	public int getCode() {
		return code;
	}

	public String getMsg() {
		return msg;
	}

	private ErrorType(int code, String msg) {
		this.code = code;
		this.msg = msg;
	}
	/**
	 * 根据code获取到msg
	 * @param code
	 * @return
	 */
	public static String getMsgByCode(int code){
		for(ErrorType e:ErrorType.values()){
			if(e.getCode()==code){
				return e.getMsg();
			}
		}
		return null;
	}
}